package lab02.test03;

import java.util.Scanner;

public class BackupMain {

    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }

        int target = scanner.nextInt();

        int[] shadow = new int[n];
        for (int i = 0; i < n; i++) {
            shadow[i] = target - array[i];
        }

        long bitmap = 0;
        for (int i = 0; i < n; i++) {

            if (target % 2 == 0 && array[i] == target / 2)
                continue;

            bitmap |= 1 << array[i] - 1;
        }

        int[] index = new int[2];
        int j = 0;

        for (int i = 0; i < n; i++) {

            if ((bitmap & (1 << (shadow[i] - 1))) == (1 << (shadow[i] - 1))) {
                index[j++] = i;
            }
        }

        System.out.println(index[0] + " " + index[1]);
    }
}
